{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d1763c97",
   "metadata": {},
   "source": [
    "# 元组（tuple）\n",
    "\n",
    "* [元组](https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences)\n",
    "> 1. 它是和list几乎完全一样的序列数据 \n",
    "> 2. 元组不可变，list可变 \n",
    "> 3. 元组的形式：（1,2,34,5,）对比 元组() 列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "df4c183e",
   "metadata": {},
   "outputs": [],
   "source": [
    "stu_id = \"100003\",\"100004\",\"100005\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8e71e0ef",
   "metadata": {},
   "source": [
    "# 字典\n",
    "--------------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cbd5441e",
   "metadata": {},
   "source": [
    "## 如何创建字典：\n",
    "\n",
    "### 1.直接按照字典的格式创建： {key1:value1 ,key2:value2 , . . . .}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "30bce57e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-10-25T08:40:54.803451Z",
     "start_time": "2021-10-25T08:40:54.781292Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'studo_10001': 'Mary', 'studo_10002': 'Jack', 'studo_10003': 'Alice'}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1. 直接按照字典的格式创建：\n",
    "stud_info = {\n",
    "    \"studo_10001\":\"Mary\",\n",
    "    \"studo_10002\":\"Jack\",\n",
    "    \"studo_10003\":\"Alice\"\n",
    "}#冒号只在字典里拥有\n",
    "stud_info"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38af9ff7",
   "metadata": {},
   "source": [
    "### 2. dic（）函数来创建字典： dict(key1 = value1,key2 = value2, . . . .)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a8abd69e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-10-25T08:44:29.652270Z",
     "start_time": "2021-10-25T08:44:29.635263Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stud_1001': 'Mary', 'stud_1002': 'Jack', 'stud_1003': 'Alice'}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info_02 = dict(\n",
    "    stud_1001 = \"Mary\",\n",
    "    stud_1002 = \"Jack\",\n",
    "    stud_1003 = \"Alice\",\n",
    ")\n",
    "stud_info_02"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d516e66",
   "metadata": {},
   "source": [
    "### 3. 字典数据增加的方式：新建空字典 dict_name = {},dict_name[key1] = value1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d813c134",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-10-25T08:48:25.039690Z",
     "start_time": "2021-10-25T08:48:25.026246Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1001: 'Mary'}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info_03 = {}\n",
    "stud_info_03[1001] = \"Mary\" \n",
    "stud_info_03"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "54c359b3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-10-25T08:49:32.829149Z",
     "start_time": "2021-10-25T08:49:32.815657Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys([1001])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stud_info_03.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a1ebae36",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
